package cn.iocoder.yudao.module.member.dal.mysql.memberconf;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.memberconf.vo.MemberConfPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.memberconf.MemberConfDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 会员主配置 Mapper
 *
 * @author doock
 */
@Mapper
public interface MemberConfMapper extends BaseMapperX<MemberConfDO> {

    default PageResult<MemberConfDO> selectPage(MemberConfPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberConfDO>()
                .eqIfPresent(MemberConfDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MemberConfDO::getPhysicalMetal, reqVO.getPhysicalMetal())
                .eqIfPresent(MemberConfDO::getPriceLockBuy, reqVO.getPriceLockBuy())
                .eqIfPresent(MemberConfDO::getPriceLockSell, reqVO.getPriceLockSell())
                .eqIfPresent(MemberConfDO::getTakeMaterial, reqVO.getTakeMaterial())
                .eqIfPresent(MemberConfDO::getStoreMaterial, reqVO.getStoreMaterial())
                .eqIfPresent(MemberConfDO::getAutoDispatchOrder, reqVO.getAutoDispatchOrder())
                .eqIfPresent(MemberConfDO::getAuthIdentity, reqVO.getAuthIdentity())
                .eqIfPresent(MemberConfDO::getDepositToPoints, reqVO.getDepositToPoints())
                .eqIfPresent(MemberConfDO::getPointsToDeposit, reqVO.getPointsToDeposit())
                .eqIfPresent(MemberConfDO::getSplitDeposit, reqVO.getSplitDeposit())
                .eqIfPresent(MemberConfDO::getSplitDepositWithoutReplenish, reqVO.getSplitDepositWithoutReplenish())
                .eqIfPresent(MemberConfDO::getShowRiskReport, reqVO.getShowRiskReport())
                .eqIfPresent(MemberConfDO::getAutoReminder, reqVO.getAutoReminder())
                .eqIfPresent(MemberConfDO::getLoanLimit, reqVO.getLoanLimit())
                .eqIfPresent(MemberConfDO::getSettlementMethod, reqVO.getSettlementMethod())
                .eqIfPresent(MemberConfDO::getAutoSettlementRatio, reqVO.getAutoSettlementRatio())
                .eqIfPresent(MemberConfDO::getAutoDepositRatio, reqVO.getAutoDepositRatio())
                .eqIfPresent(MemberConfDO::getAutoDeposit, reqVO.getAutoDeposit())
                .orderByDesc(MemberConfDO::getId));
    }

    default MemberConfDO selectByUserId(Long userId) {
        return selectOne(new LambdaQueryWrapperX<MemberConfDO>().eq(MemberConfDO::getUserId, userId));
    }
}